module.exports = class extends think.Logic {
  loginInAction() {
    this.allowMethods = 'post'; //  只允许 POST 请求类型
    const rules = {
      username: {
        string: true,
        required: true,
        trim: true,
        length: {
          min: 8,
          max: 20
        }
      },
      password: {
        required: true,
        trim: true,
        length: {
          min: 8,
          max: 20
        }
      }
    };
    const flag = this.validate(rules);
    if (!flag) {
      return this.fail('validate error', this.validateErrors);
    }
  }
};
